package com.atguigu.jxc.controller;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.*;
import com.atguigu.jxc.service.DamageListGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping
@Slf4j
public class DamageListGoodsController {

    @Autowired
    private DamageListGoodsService damageListGoodsService;


    /**
     * 保存报损单
     * @param damageList
     * @param damageListGoodsStr
     * @return
     */
    @PostMapping("/damageListGoods/save")
    public ServiceVO damageListGoods(DamageList damageList, String damageListGoodsStr, HttpSession session) {
        User currentUser = (User) session.getAttribute("currentUser");
        Integer userId = currentUser.getUserId();
        return damageListGoodsService.damageListGoods(damageList, damageListGoodsStr,userId);
    }

    /**
     * 新增报溢单
     * @param overflowList
     * @param overflowListGoodsStr
     * @param session
     * @return
     */
    @PostMapping("/overflowListGoods/save")
    public ServiceVO overflowListGoodsSave(OverflowList overflowList, String overflowListGoodsStr,HttpSession session){
        User currentUser = (User) session.getAttribute("currentUser");
        Integer userId = currentUser.getUserId();
        return damageListGoodsService.overflowListGoodsSave(overflowList,overflowListGoodsStr,userId);
    }

    /**
     * 根据时间差  查找 报损单
     * @param sTime
     * @param eTime
     * @param session
     * @return
     */
    @PostMapping("/damageListGoods/list")
    public Map<String,Object> damageListGoodsList(String  sTime, String  eTime){
        return damageListGoodsService.damageListGoodsList(sTime,eTime);
    }

    /**
     * 查询报损单商品信息
     * @param damageListId
     * @return
     */
    @PostMapping("/damageListGoods/goodsList")
    public Map<String,Object> damageListGoodsGoodsList(Integer damageListId){
        return damageListGoodsService.damageListGoodsGoodsList(damageListId);
    }

    /**
     * 报溢单查询
     * @param sTime
     * @param eTime
     * @return
     */
    @PostMapping("/overflowListGoods/list")
    public Map<String,Object> overflowListGoods(String  sTime, String  eTime){
        return damageListGoodsService.overflowListGoods(sTime,eTime);
    }
    /**
     * 报溢单商品信息
     * @param overflowListId
     * @return
     */
    @PostMapping("/overflowListGoods/goodsList")
    public Map<String,Object> overflowListGoodsList(Integer overflowListId){
        return damageListGoodsService.overflowListGoodsgoodsList(overflowListId);
    }

}
